import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import { HOME_URL } from "@/config/config";
import i18n from '@/language';


/* TabsState */
export interface TabsState {
  tabsActive: string;
  tabsList: Menu.MenuOptions[];
}

const initialState: TabsState = {
  tabsActive: HOME_URL,
  tabsList: [{ key: "homeIndex", title: i18n.t("home.home"), path: HOME_URL }]
};


export const globalSlice = createSlice({
  name: 'global',
  initialState,
  reducers: {
    setTabsList: (state, action: PayloadAction<Menu.MenuOptions[]>) => {
      state.tabsList = action.payload
    },
    setTabsActive: (state, action: PayloadAction<string>) => {
      state.tabsActive = action.payload
    },
  },
})

export const { setTabsList, setTabsActive } = globalSlice.actions

export default globalSlice.reducer